<#import "/common.ftl" as common />
<@common.commomFrame >
	<div id="breadcrumb">
		<ul class="breadcrumb">
			 <li><i class="fa fa-home"></i><a href="index-2.html">首页</a></li>
			 <li class="active">黑板报</li>
		</ul>
	</div>
	<div class="padding-md " >
		<div class="panel panel-default ">
			<div class="panel-body">
				<div class="padding-md col-md-7 col-md-offset-2">
					<div class="row">
						<div class="panel panel-default">
							<div class="panel-heading">基本信息</div>
							<form  id="trainForm" class="form-horizontal form-border" method="post" action="/train/save">
								<input type="hidden" name="trainId" id="trainId" value="${(trainId)!}"/>
								<div class="form-group">
									<label class="col-md-2 control-label text-right"><span class="text-danger">*</span>车次名称</label>
									<div class="col-md-7 ">
										<input class="form-control input-sm" type="text" placeholder="输入车次名称" 
										 name="trainName" id="trainName" value="${(trainName)!}"/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>始发站</label>
									<div class="col-md-3">
										<select name="startStationId" class="form-control chzn-select"  data-placeholder="请选择始发站">
											<option  value="0"></option>
											<#if stationList?? && stationList?size gt 0>
												<#list stationList as station>
													<option value="${(station.stationId)!}">${(station.stationName)!}</option>
												</#list>
											</#if>
										</select>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>终点站</label>
									<div class="col-md-3">
										<select name="endStationId" class="form-control chzn-select"  data-placeholder="请选择终点站">
											<option value="0"></option>
											<#if stationList?? && stationList?size gt 0>
												<#list stationList as station>
													<option value="${(station.stationId)!}">${(station.stationName)!}</option>
												</#list>
											</#if>
										</select>
									</div>
								</div>	
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>前方站</label>
									<div class="col-md-3">
										<select name="frontStationId" class="form-control chzn-select"  data-placeholder="请选择前方站">
											<option  value="0"></option>
											<#if stationList?? && stationList?size gt 0>
												<#list stationList as station>
													<option value="${(station.stationId)!}">${(station.stationName)!}</option>
												</#list>
											</#if>
										</select>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>后方站</label>
									<div class="col-md-3">
										<select name="afterStationId" class="form-control chzn-select"  data-placeholder="请选择后方站">
											<option  value="0"></option>
											<#if stationList?? && stationList?size gt 0>
												<#list stationList as station>
													<option value="${(station.stationId)!}">${(station.stationName)!}</option>
												</#list>
											</#if>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>始发时间</label>
									<div class="col-md-4">
										<div class="input-group">
											<input id="startTime" name="startTimeStr" placeholder="请点击选择始发时间" class="form-control"
												   type="text" required  value="${(station.startTime)!}"/>
											<span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
										</div>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>终点站时间</label>
									<div class="col-md-4">
										<div class="input-group">
											<input id="endTime" name="endTimeStr" placeholder="请点击选择终点站时间" class="form-control"
												   type="text" required  value="${(station.endTime)!}"/>
											<span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
										</div>
									</div>
								</div>
								
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>本站到达时间</label>
									<div class="col-md-4">
										<div class="input-group">
											<input id="reachTime" name="reachTimeStr" placeholder="请点击选择本站到达时间" class="form-control"
												   type="text" required  value="${(station.reachTime)!}"/>
											<span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
										</div>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>本站发车时间</label>
									<div class="col-md-4">
										<div class="input-group">
											<input id="leaveTime" name="leaveTimeStr" placeholder="请点击选择本站发车时间" class="form-control"
												   type="text" required value="${(station.leaveTime)!}"/>
											<span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
										</div>
									</div>
								</div>
									
								<div class="form-group">
									<label class="col-md-2 control-label"><span class="text-danger">*</span>是否上水</label>
									<div class="col-md-4">
										<label class="label-radio inline">
											<input type="radio" name="isAddWater" value="1" required="required" 
											data-parsley-required-message="是否上水"  data-parsley-errors-container="#targetUserTypeError" >
											<span class="custom-radio"></span>
											是
										</label>
										<label class="label-radio inline">
											<input type="radio" name="isAddWater" value="2" required="required"
											data-parsley-required-message="是否上水"  data-parsley-errors-container="#targetUserTypeError" >
											<span class="custom-radio"></span>
											否
										</label>
									</div>
									<span id="targetUserTypeError"></span>
									
									<label class="col-md-2 control-label"><span class="text-danger">*</span>是否去污</label>
									<div class="col-md-4">
										<label class="label-radio inline">
											<input type="radio" name="isDealRubbish" value="1" required="required" 
											data-parsley-required-message="是否去污"  data-parsley-errors-container="#targetUserTypeError" >
											<span class="custom-radio"></span>
											是
										</label>
										<label class="label-radio inline">
											<input type="radio" name="isDealRubbish" value="2" required="required"
											data-parsley-required-message="是否去污"  data-parsley-errors-container="#targetUserTypeError" >
											<span class="custom-radio"></span>
											否
										</label>
									</div>
									<span id="targetUserTypeError"></span>
								</div>
								
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>来车方向</label>
									<div class="col-md-3">
										<select name="comeDirectionId" class="form-control chzn-select"  data-placeholder="请选择来车方向" onchange="getComeSqu(this)">
											<#if comeDirectionList?? && comeDirectionList?size gt 0>
												<#list comeDirectionList as comeDirection>
													<option value="${(comeDirection.direcId)!}" data-serial="${(comeDirection.serialNumber)!}">${(comeDirection.direcName)!}</option>
												</#list>
											</#if>
										</select>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>发车方向</label>
									<div class="col-md-3">
										<select name="goDirectionId" class="form-control chzn-select"  data-placeholder="请选择始发站">
											<#if goDirectionList?? && goDirectionList?size gt 0>
												<#list goDirectionList as goDirection>
													<option value="${(goDirection.direcId)!}" data-serial="${(goDirection.serialNumber)!}">${(goDirection.direcName)!}</option>
												</#list>
											</#if>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>接车股道</label>
									<div class="col-md-3">
										<select name="pickUpTrack" class="form-control chzn-select"  data-placeholder="请选择始发站">
											<#if trackList?? && trackList?size gt 0>
												<#list trackList as track>
													<option value="${(track.trackId)!}">${(track.trackOrder)!}</option>
												</#list>
											</#if>
										</select>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>接车路径序列</label>
									<div class="col-md-3">
										<input class="form-control input-sm" type="text" placeholder="请输入关键字,以逗号分隔" readonly
											   name="pickUpSequence" value=""/>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-2 control-label"><span style="color: red">*</span>发车股道</label>
									<div class="col-md-3">
										<select name="departureTrack" class="form-control chzn-select"  data-placeholder="请选择始发站">
											<#if trackList?? && trackList?size gt 0>
												<#list trackList as track>
													<option value="${(track.trackId)!}">${(track.trackOrder)!}</option>
												</#list>
											</#if>
										</select>
									</div>
									<label class="col-md-2 control-label"><span style="color: red">*</span>发车路径序列</label>
									<div class="col-md-3">
										<input class="form-control input-sm" type="text" placeholder="请输入关键字,以逗号分隔" readonly
											   name="departureSequence" value=""/>
									</div>
								</div>
					
								<div class="panel-footer text-center">
									<button type="button" class="btn btn-success" id="submitButtonSave" onclick="addSave()" >保存</button>
									<button type="button" class="btn btn-default" onclick="history.go(-1);">返回</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	
	
	
		
	<script language="javascript">
	
		function getComeSqu(obj){
			var direc_id = obj.value;
			if(direc_id != null){
				$.ajax({
					cache: true,
					type: "POST",
					url:"/train/getComeSqu",
					data:"direcId=" + direc_id,
					async: false,
					error: function(request) {
						alertify.alert("错误：服务器异常！");
					},
					success: function(data) {
						if(data.success){
							location.href="/user/list";
						}else{
							alertify.alert("错误:" + data.message);
						}
					}
				});
			
			
			
			
			}
			
		}
	
	
	
	
	
		function addSave(){
			var trainName = $("#trainName").val();
			if($.trim(trainName) == "" ){
				alertify.alert("请输入车次！");
				return false;
			}
			
			$.ajax({
				cache: true,
				type: "POST",
				url:"/train/save",
				data:$('#trainForm').serialize(),
				async: false,
				error: function(request) {
					alertify.alert("错误：服务器异常！");
				},
				success: function(data) {
					if(data.success){
						location.href="/user/list";
					}else{
						alertify.alert("错误:" + data.message);
					}
				}
			});
		}
		
	
		
	</script>
</@common.commomFrame>